using System;
using System.Collections.Generic;
using System.Text;
using Utility;
using Entities;
using DAL;
namespace BUS
{
    public class tbMienBUS
    {
        public static void Insert(tbMien m)
        {
            tbMienDAL mDAL = new tbMienDAL();
            mDAL.Insert(m);
        }
        public static void Update(tbMien m)
        {
            tbMienDAL mDAL = new tbMienDAL();
            mDAL.Update(m);
        }
        public static void Delete(int iD)
        {
            tbMienDAL mDAL = new tbMienDAL();
            mDAL.Delete(iD);
        }
        public static tbMienCollection Get(string where, int pageindex, int pagesize, string orderby, string orderdirection, out int total)
        {
            tbMienDAL mDAL = new tbMienDAL();
            return mDAL.Get(where, pageindex, pagesize, orderby, orderdirection, out total);
        }
        public static tbMienCollection GetAll()
        {
            int total = 0;
            Criteria cri = new Criteria();
            tbMienDAL mDAL = new tbMienDAL();
            return mDAL.Get(cri.Criter, 0, 0,tbMiencolumn .mamien .ToString(), OrderDirection.ASC.ToString(), out total);
        }
        public static tbMien GetByID(int iD)
        {
            int total = 0;
            Criteria cri = new Criteria();
            cri.add(Condition.AND, tbMiencolumn .mamien .ToString(), Condition.EQUAL, iD);
            tbMienDAL mDAL = new tbMienDAL();
            tbMienCollection mColl = mDAL.Get(cri.Criter, 0, 0,tbMiencolumn .mamien  .ToString(), OrderDirection.ASC.ToString(), out total);
            if (mColl.Count > 0)
                return mColl[0];
            return null;
        }
        //public static tbDiadanhCollection GetLimited(int number)
        //{
        //    int total = 0;
        //    Criteria cri = new Criteria();
        //    tbDiadanhDAL ddDAL = new tbDiadanhDAL();
        //    return ddDAL.Get(cri.Criter, 1, number,
        //    tbDiadanhCollumn.madiadanh.ToString(), OrderDirection.DESC.ToString(), out total);
        //}
        //public static tbDiadanhCollection GetPromotion(int number)
        //{
        //    int total = 0;
        //    Criteria cri = new Criteria();
        //    tbDiadanhDAL ddDAL = new tbDiadanhDAL();
        //    return ddDAL.Get(cri.Criter, 1, number,
        //    tbDiadanhCollumn.madiadanh.ToString(), OrderDirection.DESC.ToString(), out total);
        //}
    }
}
